package com.bw.lib_mvvm

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import androidx.fragment.app.Fragment

/**
 *@ClassName BaseFragment
 *@Author hu..
 *@Data 2024/7/21
 *@Description
 */
abstract class BaseFragment <VDB: ViewDataBinding>: Fragment(){
    protected lateinit var viewDataBinding: VDB

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        viewDataBinding = DataBindingUtil.inflate(inflater,bindLayout(),container,false)

        return super.onCreateView(inflater, container, savedInstanceState)
    }

    abstract fun bindLayout(): Int

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)

        initView()
        initData()
    }

    abstract fun initView()

    abstract fun initData()
}